/*
 * @Author: your name
 * @Date: 2022-07-14 15:25:11
 * @LastEditTime: 2022-07-14 17:41:48
 * @LastEditors: NB-SZ-658
 * @Description: In User Settings Edit
 * @FilePath: \antd-demo-ts\src\store\reducers\layoutsRouter.ts
 */
import { layoutsData } from '../../mock'
import { ROUTER_SWITCH } from '../constants'
const inieState: any = {
    routerData: layoutsData || [],
    defaultRouter: '/',
    ParentRouter: ''
}
export default function layoutsRouter(state = inieState, action: any) {
    switch (action.type) {
        case ROUTER_SWITCH: {
            let ParentRouterInit = ''
            try {
                let Init = action.parms.split('/')[action.parms.split('/').length - 2] || ''
                ParentRouterInit = Init ? `/${Init}` : ''
                console.log(ParentRouterInit)
            } catch { }
            return {
                ...state,
                defaultRouter: action.parms,
                ParentRouter: ParentRouterInit
            }
        }
        default: {
            return state
        }
    }
}
